package com.tszs.Controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tszs.biz.AccessLogBiz;
import com.tszs.entity.AccessLog;
import com.tszs.util.CallBack;

import net.sf.json.JSONObject;

/**
 * @类名:AdministratorTableController
 * @类描述：管理员表操作 @创建时间：2019-03-22 13:07:07
 * @创建人：王俊
 * @author Administrator
 *
 */
@Controller
public class AccessLogController {
	/**
	 * @AccessLogBiz
	 */
	@Autowired
	private AccessLogBiz accessLogBiz;
	/**
	 * @方法名:AccessLogPage
	 * @方法描述:日志查看 
	 * @创建时间：2019-03-22 13:07:07
	 * @创建人：王俊
	 * @author Administrator
	 *
	 */
	@RequestMapping("pc/admin/AccessLogPage")
	public void AccessLogPage(HttpServletResponse response,HttpServletRequest request) {
		response.setContentType("text/xml; charset=UTF-8");
		response.setContentType("text/html;charset=utf-8");
		int page = Integer.parseInt(request.getParameter("page"));
		int limit = Integer.parseInt(request.getParameter("limit"));
		AccessLog record = new AccessLog();
		record.setPage((page - 1) * limit);
		record.setLimit(limit);
		List<AccessLog> selectByExamplePage = accessLogBiz.selectByExamplePage(record);
		AccessLog record1 = new AccessLog();
		int page2=0;
		int limit2=0;
		record1.setPage((page2 - 1) * limit2);
		record1.setLimit(limit2);
		List<AccessLog> selectByExamplePage1 = accessLogBiz.selectByExamplePage(record1);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("msg", "");
		map.put("count", selectByExamplePage1.size());
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		for (int i = 0; i < selectByExamplePage.size(); i++) {
			Map<String, Object> mapData = new HashMap<String, Object>();
			mapData.put("aId", i + 1);
			mapData.put("UserId", selectByExamplePage.get(i).getUserId());
			mapData.put("UserName", selectByExamplePage.get(i).getUserName());
			mapData.put("UserAddress", selectByExamplePage.get(i).getUserAddress());
			mapData.put("aStatic", selectByExamplePage.get(i).getaStatic());
			mapData.put("aCreateTime", selectByExamplePage.get(i).getaCreateTime());
			list.add(mapData);
		}
		map.put("data", list);
		JSONObject json = JSONObject.fromObject(map);
		new CallBack().textObject(json, response);
	}
}
